package com.mythesis.bpel.ui.client.controls;

import com.allen_sauer.gwt.dnd.client.HasDragHandle;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.mythesis.bpel.ui.client.wrapper.ControlWrapper;

public class BpelControl extends Composite implements HasDragHandle{
	private Image image;
	private Label label;
	private HorizontalPanel hPanel;
	private FocusPanel handle;
	protected ControlWrapper controlWrapper;
	
	public ControlWrapper getControlWrapper() {
		return controlWrapper;
	}

	public void setControlWrapper(ControlWrapper controlWrapper) {
		this.controlWrapper = controlWrapper;
	}

	public BpelControl(Image image, Label label){
		this.image = image;
		this.label = label;
		hPanel = new HorizontalPanel();
		hPanel.add(image);
		hPanel.add(label);
		handle = new FocusPanel();
		handle.setWidget(hPanel);
		initWidget(handle);
	}
	
	public BpelControl cloneControl() {
		Image _image;
		Label _label;
		_image = new Image(image.getUrl());
		_label = new Label(label.getText());
	    return new BpelControl(_image, _label);
	};
	
	@Override
	public Widget getDragHandle() {
		return handle;
	}
	
}
